<template>
  <div>
    <ZgDialog v-model="visible" title="设置数据类型" @ok="onOk">
      <ZgCheckbox v-model="t.ck" v-for="(t,i) in dataTypeArr" :key="i">{{ t.name }}</ZgCheckbox>
    </ZgDialog>
  </div>
</template>
<script>
export default {
  data () {
    return {
      visible: false,
      dataTypeArr: [
        { key: '1', name: '某某数据', type: 1, ck: false },
        { key: '2', name: '某某数据', type: 2, ck: false },
        { key: '3', name: '某某数据', type: 1, ck: false },
        { key: '4', name: '某某数据', type: 1, ck: false },
        { key: '5', name: '某某数据', type: 5, ck: false }
      ]
    }
  },
  mounted () {
  },
  methods: {
    open () {
      this.visible = true
    },
    onOk () {
      const arr = this.dataTypeArr.filter(t => { return t.ck })
      if (arr.length === 0) {
        this.$error({ title: '请选择一个数据类型' })
        return
      }
      this.visible = false
      this.$emit('ok', JSON.stringify(arr))
    }
  }
}
</script>

<style lang="scss" scoped>
</style>
